package assignmentstrategy

import (
	"codejy/analysis/codeanalysis"
	"codejy/store"
	"codejy/structdef"
)

type TypePropertyStrategy struct {
}

func init() {
	RegisterStrategy(&TypePropertyStrategy{})
}
func (n TypePropertyStrategy) getId() int {
	return codeanalysis.TypePropert
}

func (n TypePropertyStrategy) Execute(threadStore *structdef.ThreadStore, code string) string {
	currentInstanceAddress := threadStore.CurrentInstanceAddress
	prop, _ := store.GetInstanceProp(threadStore, currentInstanceAddress)
	definition, _ := prop[code]
	//当前实例拿不到去获取父实例
	parentInstanceAddress := threadStore.ParentInstanceAddress
	if definition.Name == "" && parentInstanceAddress != currentInstanceAddress {
		prop, _ = store.GetInstanceProp(threadStore, parentInstanceAddress)
		definition, _ = prop[code]
	}
	return definition.Value
}
